package com.dms.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.dms.dao.DomitoryDao;
import com.dms.model.Domitory;

@Repository
public class DomitoryDaoImpl extends BaseDaoImpl implements DomitoryDao {

	@Override
	public Domitory getDomitory(String hql) {	
		return (Domitory) getSession().createQuery(hql).uniqueResult();
	}

	@Override
	public void updateDomitory(Domitory domitory) {
		Session session=this.getSession();
		session.merge(domitory);
		session.flush();
		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Domitory> getDomitorys(String hql) {
		return getSession().createQuery(hql).list();
	}

	@Override
	public void save(Domitory domitory) {
		this.getSession().save(domitory);
		
	}

	@Override
	public void delete(int id) {
		Session session=this.getSession();
		session.delete(session.get(Domitory.class, id));
		session.flush();
	}

	

}
